package com.wanmait.zaisousuo.service.Impl;

import com.alibaba.fastjson.JSON;
import com.wanmait.zaisousuo.mapper.DataMapper;
import com.wanmait.zaisousuo.pojo.Data;
import com.wanmait.zaisousuo.service.DataService;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
@Transactional
public class DataServiceImpl implements DataService {

    @Resource
    private DataMapper dataMapper;

    //最近三十天各种垃圾的数据
    @Cacheable(value = "CompanyDataCache",key = "'findLastThirtyDaysData'")
    @Override
    public List<Data> findLastThirtyDaysData() {
        return dataMapper.findThirtyDaysData();
    }

    //过去十二个月该垃圾在该城市的数据
    @Cacheable(value = "CompanyDataCache",key = "'findLastTwelveMonthsData'+#garbageId+'id='+#cityId")
    @Override
    public List<Data> findLastTwelveMonthsData(Integer garbageId,Integer cityId) {
        List<Data> dataList =  dataMapper.findLastTwelveMonthsData(garbageId, cityId);
        return dataList;
    }

    //释放量最大的8个城市排名
    @Cacheable(value = "CompanyDataCache",key = "'findMostOutCity'")
    @Override
    public List<Data> findMostOutCity() {
        return dataMapper.findMostOutCity();
    }

    //回收率最高的8个城市
    @Cacheable(value = "CompanyDataCache",key = "'findMostRecycleCity'")
    @Override
    public List<Data> findMostRecycleCity() {
        return dataMapper.findMostRecycleCity();
    }


}
